#!/bin/bash
docker_name="ros-learn"

xhost +

function run_have_docker(){
    sudo docker start ${docker_name}
    sudo docker exec -it ${docker_name} /bin/bash
}

function create_docker(){
    #sudo docker rm -f ${docker_name}
    sudo docker run -it --name ${docker_name} --net=host \
        -e DISPLAY=unix$DISPLAY --ulimit core=-1 --security-opt seccomp=unconfined \
        -v /tmp/.X11-unix/:/tmp/.X11-unix/ --privileged \
        -v /dev:/dev:ro \
        -e LANG=en_US.UTF-8 \
        -e LANGUAGE=en_US:en \
        -v /etc/timezone:/etc/timezone:ro \
        -v $(pwd):/home/work -w /home/work \
        ros:kinetic-ros-zyf /bin/bash
}

have=$(docker ps -a | grep ros-learn)

if [ -z "${have}" ] 
then
    create_docker
else
    run_have_docker
fi

